From 130eaed72175148b36bcd4a469426fb53660e672 Mon Sep 17 00:00:00 2001 From: Andrew Watts Date: Fri, 21 Apr 2017 12:06:32 +0930 Subject: [PATCH] Add test case for non-deterministic rustc flags due to dependencies --- tests/build-script.rs | 113 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/tests/build-script.rs b/tests/build-script.rs index 7356af284..da2a45649 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -2592,3 +2592,116 @@ fn if_build_set_to_false_dont_treat_build_rs_as_build_script() { assert_that(p.cargo("run").arg("-v"), execs().with_status(0)); } + +#[test] +fn deterministic_rustc_dependency_flags() { + // This bug is non-deterministic hence the large number of dependencies + // in the hopes it will have a much higher chance of triggering it. + + Package::new("dep1", "0.1.0") + .file("Cargo.toml", r#" + [project] + name = "dep1" + version = "0.1.0" + authors = [] + build = "build.rs" + "#) + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-flags=-L native=test1"); + } + "#) + .file("src/lib.rs", "") + .publish(); + Package::new("dep2", "0.1.0") + .file("Cargo.toml", r#" + [project] + name = "dep2" + version = "0.1.0" + authors = [] + build = "build.rs" + "#) + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-flags=-L native=test2"); + } + "#) + .file("src/lib.rs", "") + .publish(); + Package::new("dep3", "0.1.0") + .file("Cargo.toml", r#" + [project] + name = "dep3" + version = "0.1.0" + authors = [] + build = "build.rs" + "#) + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-flags=-L native=test3"); + } + "#) + .file("src/lib.rs", "") + .publish(); + Package::new("dep4", "0.1.0") + .file("Cargo.toml", r#" + [project] + name = "dep4" + version = "0.1.0" + authors = [] + build = "build.rs" + "#) + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-flags=-L native=test4"); + } + "#) + .file("src/lib.rs", "") + .publish(); + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + dep1 = "*" + dep2 = "*" + dep3 = "*" + dep4 = "*" + "#) + .file("src/main.rs", r#" + fn main() {} + "#); + + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0) + .with_stderr("\ +[UPDATING] [..] +[DOWNLOADING] [..] +[DOWNLOADING] [..] +[DOWNLOADING] [..] +[DOWNLOADING] [..] +[COMPILING] [..] +[COMPILING] [..] +[COMPILING] [..] +[COMPILING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[RUNNING] [..] +[COMPILING] foo v0.1.0 [..] +[RUNNING] `rustc --crate-name foo [..] -L native=test1 -L native=test2 \ +-L native=test3 -L native=test4` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")); +} -- 2.30.2